package com.example.administrator.myapplication.find.recommend.bean.recommendEntity;

import android.databinding.ObservableInt;
import android.support.design.widget.Snackbar;
import android.support.v4.view.PagerAdapter;

import com.example.administrator.myapplication.BR;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.until.CommentPagerAdapter;
import com.google.gson.annotations.Expose;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

/**
 * Created by Administrator on 2017.1.29.
 */
public class DiscoveryColumns {
    private int ret;

    private String title;

    private List<DiscoveryColumnsData> list ;

    private int locationInHotRecommend;
    @Expose(serialize = false,deserialize = false)
    private PagerAdapter adapter;
    @Expose(serialize = false,deserialize = false)
    private ObservableInt pager = new ObservableInt(0);
    public PagerAdapter getAdapter() {
        if(adapter==null){
            List<List<DiscoveryColumnsData>> lists = new ArrayList<>();
            //开始每4个  分一组
            for (int i = 0; i < list.size(); i += 4) {
                List<DiscoveryColumnsData> group= new ArrayList<>();
                for (int j = i; j < Math.min(i + 4, list.size()); j++) {
                    group.add(list.get(j));
                }
                lists.add(group);
            }
           adapter = new CommentPagerAdapter<>(lists, R.layout.recommend_discovers, BR.discovers);
        }
        return adapter;
    }

    public void setAdapter(PagerAdapter adapter) {
        this.adapter = adapter;
    }

    public ObservableInt getPager() {
        return pager;
    }

    public void setPager(ObservableInt pager) {
        this.pager = pager;
    }

    public int getRet() {
        return ret;
    }

    public void setRet(int ret) {
        this.ret = ret;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<DiscoveryColumnsData> getList() {
        return list;
    }

    public void setList(List<DiscoveryColumnsData> list) {
        this.list = list;
    }

    public int getLocationInHotRecommend() {
        return locationInHotRecommend;
    }

    public void setLocationInHotRecommend(int locationInHotRecommend) {
        this.locationInHotRecommend = locationInHotRecommend;
    }
}
